<template>
  <div class="programming-card">
    <van-nav-bar
      title="编程思维积木"
      left-arrow
      @click-left="$emit('close')"
    />
    
    <div class="card-content" v-if="cardData">
      <div v-html="cardData.content"></div>
    </div>
    
    <div class="loading" v-else>
      <van-loading type="spinner" color="#6e8efb" size="24px">生成思维积木中...</van-loading>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { useRoute } from 'vue-router';

const props = defineProps({
  cardData: {
    type: Object,
    required: true
  }
});

defineEmits(['close']);

// 添加全局样式
const style = document.createElement('style');
style.textContent = `
  .programming-card {
    min-height: 100vh;
    background-color: #f5f7fa;
  }
  
  .card-content {
    padding: 16px;
  }
  
  .card-content :deep(h1) {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
  }
  
  .card-content :deep(section) {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  }
  
  .card-content :deep(section h2) {
    font-size: 18px;
    color: #6e8efb;
    margin-bottom: 12px;
  }
  
  .card-content :deep(section p) {
    font-size: 16px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 8px;
  }
  
  .card-content :deep(section ul) {
    padding-left: 20px;
    margin-bottom: 12px;
  }
  
  .card-content :deep(section li) {
    font-size: 15px;
    color: #666;
    margin-bottom: 8px;
  }
  
  .card-content :deep(svg) {
    width: 100%;
    max-width: 300px;
    height: auto;
    margin: 16px auto;
    display: block;
  }
  
  .loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
  }
  
  @media (max-width: 768px) {
    .card-content {
      padding: 12px;
    }
    
    .card-content :deep(h1) {
      font-size: 20px;
    }
    
    .card-content :deep(section h2) {
      font-size: 16px;
    }
    
    .card-content :deep(section p),
    .card-content :deep(section li) {
      font-size: 14px;
    }
  }
`;

onMounted(() => {
  document.head.appendChild(style);
});
</script> 